package com.saic.data.dotask;

import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.hadoop.hbase.client.Put;

import com.saic.data.table.TableUtil;
import com.saic.data.util.HbaseUtil;

import it.sauronsoftware.ftp4j.FTPFile;

/**
 * @Desc:Hbase insert into data
 * @author Xinshiyou
 */
public class AddDataTask extends DoTask {

	private String tabName;
	private FTPFile f;

	public AddDataTask(String tabName,FTPFile f) {
		this.tabName = tabName;
		this.f = f;
	}

	@Override
	public void doTask() {
		try {
			Map<String, String> map = new HashMap<String, String>();
			map = TableUtil.getFileMap(f);
			Put put = HbaseUtil.getPutFromMap(tabName,TableUtil.configtabFamily,
					TableUtil.getKey(new Date(), f.getName().split("\\,")[0]),map );
			result = HbaseUtil.insertData(tabName,put);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}



}
